
// 请求发送的次数
let  ajaxnum = 0
// 封装数据请求
export const request = (params)=>{
  ajaxnum++
  wx.showLoading({
    title: '加载中',
  })
  let baseUrl = "https://api-hmugo-web.itheima.net/api/public/v1"
  return new Promise((resolve,reject)=>{ 
      wx.request({ 
        ...params,
        url:baseUrl + params.url, 
        success: (result) => {
          resolve(result.data.message)
        },
        fail: (err) => {
          reject(err)
        },
        complete:()=>{
          ajaxnum--
          if(ajaxnum==0){
            wx.hideLoading()
          }
        }
      })
  })
}


